package com.linchong.concurrency.aqs;

import lombok.extern.slf4j.Slf4j;

import java.util.Comparator;
import java.util.concurrent.*;

/**
 * @author linchong
 * @version 1.0
 * @Date: 2020-12-09 11:29
 * @Description: FutureTaskExample
 */
@Slf4j
public class FutureTaskExample {



	public static void main(String[] args) throws Exception {
		FutureTask<String> futureTask = new FutureTask<>(() -> {
			log.info("do something in callable");
			Thread.sleep(4_000);
			return "Done";
		});

		new Thread(futureTask).start();
		log.info("do something in main");
		String result = futureTask.get();
		log.info("result:{}",result);

	}
}














